#ifndef ACTION_H_INCLUDED
#define ACTION_H_INCLUDED

#include "Database.h"
#include "Digest.h"

class Action
{
public:
    Action(Database* db)
    {
        ThisDatabase = db;

        ThisDigest = new MD5();
    };

    ~Action()
    {
        if(ThisDigest)
            delete ThisDigest;
    };

private:
    Database* ThisDatabase;
    string CurrentKeyword;

private:
    Action();
    Book* GetBookFromPoolOrDatabase(uint32_t BookID);

public:
    BPcode ImportBooksFromDirectory(Bchar* ThisDirectory);
    BPcode RefreshBooksFromDirectory();

    void ReadPage(uint32_t Page, string Keyword);
    void ReadNextPage();
    void ReadPreviousPage();

    Book* GetBookAndHistorysFromPoolOrInsert(uint32_t BookID);
    Book* RefreshHistorysFromDatabase(uint32_t BookID);
    BPcode AddHisotryIntoTheBookNPool(uint32_t BookID, History* NewHistory);
    BPcode DeleteHistoryFromBookNPool(uint32_t BookID, uint32_t HistoryID);

private:
    Digest* ThisDigest;
};

#endif // ACTION_H_INCLUDED
